package com.qf.mapper.impl;

import com.qf.mapper.ProvinceMapper;
import com.qf.pojo.City;
import com.qf.pojo.Province;
import com.qf.utils.DBUtils;

import java.sql.SQLException;
import java.util.List;

public class ProvinceMapperImpl implements ProvinceMapper {
    @Override
    public List<Province> getProvinces() {
        try {
            List<Province> provinces = DBUtils.commonQueryList(Province.class, "select * from provinces where parent_code=?", "01");
            return provinces;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public List<City> getCities(String parentCode) {
        try {
            List<City> cities = DBUtils.commonQueryList(City.class, "select * from provinces where parent_code=?", parentCode);
            return cities;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
